<?php

class lastfm_events extends feed {
	
	static function getEvents($artist, $limit = 10) {
		
		$results = array();
		
		// get feed
		$url = 'http://ws.audioscrobbler.com/1.0/artist/'.$artist.'/events.rss';
		$xml = self::loadRaw($url, config::getInstance()->lastfm_events_ttl);
		$rss = phpQuery::newDocumentXML($xml)->find("channel > item");
		
		$i = 0;
		// loop entries
		foreach ($rss as $entry) {
			if ($i >= $limit) {
				continue;
			}
			$result['title'] = pq($entry)->find("title")->text();
			$result['link'] = pq($entry)->find("link")->text();
			$results[] = $result;
			$i++;			
		}

		return $results;		
	}
	
}

?>